<%@ page language="java" contentType="text/html;charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="${ctx}/css/b.css">
<link rel="stylesheet" type="text/css" href="${ctx }/css/css.css">
<link rel="stylesheet" type="text/css" href="${ctx }/css/main.css">
<link rel="stylesheet" type="text/css" href="${ctx }/css/mybutton.css">
<title>长江师范学院失物招领中心-用户注册</title>
<script src="${ctx}/assets/js/jquery.min.js" ></script>
<script src="${ctx }/js/ajaxupload.js"></script>
<script src="${ctx}/js/date/WdatePicker.js" ></script>
<style type="text/css">
	body{
		font-family: '微软雅黑';
	}
	.head_div{
		text-align: right;
		font-size: 12px;
		padding-right: 20px;
		background-color: currentColor;
	}
	.head_msg{
		color: white;
	}

</style>  
</head>


<body style="padding: 0px;" class="response-wider">

	<!--导航菜单-->
	<div class="MainMenu" style="margin-bottom: 8px;">
		<div class="MenuList" style="min-width: 500px; background: transparent none repeat scroll 0% 0%;">
			<dl>
				<dt>
					<a href="${ctx }/swzl/index"><div>首页</div></a>
				</dt>
			</dl>
			<dl>
				<dt>
					<c:if test="${not empty swzlUser}">
						<a href="${ctx }/swzl/userInfo?type=myInfo"><div>${swzlUser.name }</div></a>
					</c:if>
					<c:if test="${empty swzlUser}">
						<a href="${ctx }/swzl/userInfo?type=goLogin"><div>登录/注册</div></a>
					</c:if>
				</dt>
			</dl>
			<dl>
				<dt>
					<a href="${ctx }/swzl/index?typeParentId=1"><div>失物招领</div></a>
				</dt>
			</dl>
			<dl>
				<dt>
					<a href="${ctx }/swzl/index?typeParentId=2"><div>寻物启事</div></a>
				</dt>
			</dl>
			<dl>
				<dt>
					<a href="${ctx }/swzl/index?typeParentId=3"><div>我发布的</div></a>
				</dt>
			</dl>
			<c:if test="${not empty swzlUser}">
				<dl>
					<dt>
						<a href="${ctx }/swzl/userInfo?type=loginOut"><div>退出</div></a>
					</dt>
				</dl>
			</c:if>						
		</div>
	</div>
<!-- 导航菜单 -->

 	<div class="content-rightk" style="margin: 0px auto; width: 1080px; background: transparent none repeat scroll 0% 0%; float: none;"> 

        <div class="content-right z_content" style="margin: 0px auto; width: 1070px; background: transparent none repeat scroll 0% 0%; float: none;">
          
          
          <h5 style="background: rgb(221, 221, 221) none repeat scroll 0% 0%;">发布消息</h5>
          
          <!-- start:表单开始 -->
          <div class="z_from">
          
			
            <!-- start:必填信息 -->
            <h4 style="border-top: 1px solid rgb(228, 55, 22);">发布消息</h4>
            <div class="form-horizontal">
              
	            <div class="control-group">
	                <label class="control-label"><img src="${ctx }/images/redx.png">消息图片：</label>
	                <div class="controls" style="overflow: hidden;" id="messageImgs">
	                	
			           
	                </div>
	                <button style="margin-top: 8px;margin-left:195px; width: 100px; display: block;" class="button button-glow button-rounded button-raised button-primary" id="addLabProdPic">上传图片</button>
	             </div>


                          
              <div class="control-group">
                <label class="control-label"><img src="${ctx }/images/redx.png">标题：</label>
                <div class="controls">
                  <input id="title" name="title" size="20" maxlength="14" value="" placeholder="请填写标题" type="text">
                </div>
              </div>
              

              <div class="control-group">
                <label class="control-label"><img src="${ctx }/images/redx.png">消息类型：</label>
              <div class="controls">
	            <select name="parent_type" id="parent_type"  >
	            	<option value="">请选择</option>
	                <option value="1">失物招领</option>
	                <option value="2">寻物启事</option>
	            </select>
	               </div>
              </div>

              <div class="control-group">
                <label class="control-label"><img src="${ctx }/images/redx.png">物品类型：</label>
              <div class="controls">
	            <select name="goodsType" id="goodsType">
	                <option value="">请先选择消息类型</option>
	            </select>
               </div>
              </div>



              <div class="control-group" style="display: block;">
                <label class="control-label" id="realNameLabel"><img src="${ctx }/images/redx.png">失物/拾物地址：</label>
                <div class="controls">
                  <input name="address" id="address" value="" maxlength="50" placeholder="请填写地址" type="text">
                  <span class="notic_info" id="realNameExample">
                  	例如:图书馆
                  </span>
	              <div style="color: red; display: none;" id="realNameInvalid">
	              </div> 
	              <input id="realNameFine" type="hidden">                     
                </div>
              </div> 

              <div class="control-group" style="display: block;">
                <label class="control-label" id="realNameLabel"><img src="${ctx }/images/redx.png">失物/拾物时间：</label>
                <div class="controls">
                 <input class="Wdate" type="text" onClick="WdatePicker()" id="lostTime" placeholder="请选择时间">
                </div>
              </div> 

              <div class="control-group" style="display: block;">
                <label class="control-label" id="realNameLabel"><img src="${ctx }/images/redx.png">详细内容：</label>
                <div class="controls">
                  <textarea id="detailContent" cols="5" rows="4"></textarea>
                </div>
              </div> 

         


				<button style="margin-top:  15px;margin-left: 180px; width: 180px; display: block;" class="button button-glow button-rounded button-raised button-primary" id="submit">发布</button>

            </div>
  
          </div>
        </div>
</div>




<div style="width: 100%; background: rgb(239, 239, 239) none repeat scroll 0% 0%; padding: 0px; height: 85px; display: block; font-size: 11px; line-height: 15px; margin: 0px; font-family: Roboto-Regular,微软雅黑,宋体,Arial,sans-serif;"> 
      <div style="vertical-align: middle; background: transparent none repeat scroll 0% 0%; padding-top: 8px; text-align: center; color: rgb(102, 102, 102);">
        ©Copyright2017 <a href="#" target="_blank" style="color: rgb(102, 102, 102);">长江师范失物招领</a> All Rights Reserved
	  </div>
       
      <div style="vertical-align: middle; background: transparent none repeat scroll 0% 0%; margin: 10px auto; text-align: center;">
                 邮箱：<a href="#">895243872@qq.com</a>
	  </div>
       
	 	<div style="width: 300px; margin: 0px auto; padding: 0px; text-align: center;">
	 		<a target="_blank" href="#" style="display: inline-block; text-decoration: none; height: 20px; line-height: 20px;">
		 		<img src="${ctx }/images/gongAnBeiAnLogo.png" style="float: left;" data-bd-imgshare-binded="1">
		 		<p style="float: left; height: 20px; line-height: 20px; margin: 0px 0px 0px 5px; color: rgb(147, 147, 147);">
		 			渝公网安备 000000000000000号
		 		</p>
	 		</a>
	 	</div>
		 	   
</div>
<script type="text/javascript">

//上传图片
new AjaxUpload('#addLabProdPic', {
	action: '${ctx}/upload', 
	name: 'picFile',
	responseType: 'json',
	onSubmit : function(file , ext){
		if (ext && /^(jpg|png|bmp)$/.test(ext.toLowerCase())){
			this.setData({
				'picName': file
			});
		} else {
			alert("请上传格式为 jpg|png|bmp 的图片！");
			return false;				
		}
	},
	onComplete : function(file,response){
		if(response.error) {
			alert(response.error);
			return;
		}
		var html="<div class='resizebox' style='width: 100px;position: relative; height:100px;margin-top: 11px;margin-left: 15px;border: 1px solid #ccc;float: left;'>"
		+"<img src='"+response.picUrl+"' id='head_img' style='width: 100px;height: 100px;'><span class='close' onclick='closeImg(this)'>X</span> </div>";
		$("#messageImgs").append(html);
  
	}		
});
function closeImg(obj){
	$(obj).parent().remove();
	
}
$("#parent_type").on("change",function(){
	var parentId=$(this).val();
	if(!parentId){
		  $("#goodsType").html(" <option value=''>请先选择消息类型</option>");
		return;
	}
	var datas={"parentId":parentId};
	$.ajax({
		  type: 'post',
		  url: "${ctx}/swzl/messageType?type=queryByParentId",
		  data: datas,
		  dataType: "json",
		  success: function(data){
			  if(data.returnCode==200){
				  var list=data.data;
				  if(list){
					  var html="";
					  for(var i=0;i<list.length;i++){
						  html+="<option value='"+list[i].id+"'>"+list[i].name+"</option>";
					  }
					  $("#goodsType").html(html);
				  }
			  }else{
				  alert(data.returnMsg);
			  }
		  },error:function(){
			  alert("系统异常");
		  }
	});
	
	
	
});

$("#submit").on("click",function(){
	var messageImgs=[];
	$("#messageImgs").find("img").each(function(i,obj){
		messageImgs.push($(obj).attr("src"));
	});
	
	var datas={"messageImgs":messageImgs.join(","),"title":$("#title").val(),"goodsType":$("#goodsType").val(),"address":$("#address").val(),"lostTime":$("#lostTime").val(),"detailContent":$("#detailContent").val()};
	$.ajax({
		  type: 'post',
		  url: "${ctx}/auth/swzl/message?type=releaseMessage",
		  data: datas,
		  dataType: "json",
		  success: function(data){
			  if(data.returnCode==200){
				  location.href="${ctx}/swzl/index?typeParentId=3";
			  }else{
				  alert(data.returnMsg);
			  }
		  },error:function(){
			  alert("系统异常");
		  }
	});
	
	
});



</script>



</body>
</html>


